package com.mobiftpcms.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;


@Entity
@Table(name="log")
@Searchable
public class Log extends BaseObject implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -675134110353979264L;

	private Long id;
	
	private Date time;
	
	private String taskName;
	
	private String taskReference;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@SearchableId
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "time", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
    @SearchableProperty
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@Column(name = "task_name", nullable = false, length = 100)
    @SearchableProperty
	public String getTaskName() {
		return taskName;
	}

	
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	@Column(name = "task_reference", nullable = false, length = 1000)
    @SearchableProperty
	public String getTaskReference() {
		return taskReference;
	}

	public void setTaskReference(String taskReference) {
		this.taskReference = taskReference;
	}

	@Override
	public String toString() {
		return getTaskName() + " " + getTaskReference();
	}

	@Override
	public boolean equals(Object o) {
		if(o != null) {
			if(o instanceof Log) {
				Log l = (Log) o;
				return l.getId().equals(getId());
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return getId().intValue();
	}
	
}
